<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<base href="${pageContext.request.contextPath }/">
<title>CPI大数据编辑</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="css/pagestyle.css" type="text/css">
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
	function datachild() {
		$.ajax({
			type : "get",
			url : "DataTypeServlet?parentid=" + $("#datatype").val(),
			async : true,
			dataType : "json",
			success : cpidatatype,
			error : errorinfo
		});
	}
	function cpidatatype(data) {
		var str = "";
		$(data)
				.each(
						function(i) {
							if (data[i].datatypeid == "${datatypechildval}")
								str += "<option value='"+data[i].datatypeid+"' selected='selected'>"
										+ data[i].datatypename + "</option>";
							else
								str += "<option value='"+data[i].datatypeid+"'>"
										+ data[i].datatypename + "</option>";
						});
		$("#datatypechild").html(str);
	}
	function errorinfo() {
		alert("请求服务器失败");
	}
	$(function() {
		datachild();
	});

	/* 检查时间是否填入  */
	function checkdate() {
		if ($("#cpidate").val() == "") {
			alert("选择的时间不能为空！");
			return false;
		} else {
			return true;
		}
	}
	
</script>
</head>
<body>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td width="153" height="48"><img src="images/projectmanager.gif"
				width="153" height="48"></td>
			<td background="images/maintitle-bg.gif">&nbsp;</td>
			<td width="80"><img src="images/maintitle-right.gif" width="80"
				height="48"></td>
		</tr>
	</table>
	<table width="100%" border="0" cellpadding="0" cellspacing="0"
		class="pagenav">
		<tr>
			<td width="700" height="22">
				<form action="DataViewServlet?type=date" method="post"
					onsubmit="return checkdate()">
					<table width="600" border="0" cellpadding="0" cellspacing="5">
						<tr>
							<td nowrap><strong>搜索条件：</strong>CPI数据分析报表 <select
								id="datatype" name="datatype" onchange="datachild()">
									<c:forEach items="${datatype}" var="item">
										<c:choose>
											<c:when test="${datatypeval eq item.datatypeid}">
												<option value="${item.datatypeid}" selected="selected">${item.datatypename}</option>
											</c:when>
											<c:otherwise>
												<option value="${item.datatypeid}">${item.datatypename}</option>
											</c:otherwise>
										</c:choose>
									</c:forEach>
							</select> CPI数据子类 <select id="datatypechild" name="datatypechild">

							</select> &nbsp;&nbsp;数据来源区域 <select id="dataarea" name="dataarea">
									<c:forEach items="${areatype}" var="item">
										<c:choose>
											<c:when test="${item.areaid eq dataareaval }">
												<option value="${item.areaid}" selected="selected">${item.areaname}</option>
											</c:when>
											<c:otherwise>
												<option value="${item.areaid}">${item.areaname}</option>
											</c:otherwise>
										</c:choose>
									</c:forEach>
							</select>&nbsp;&nbsp;时间 <input type="month" id="cpidate" name="cpidate"
								value="${cpidateval }"></td>
							<td><input id="btnsubmit" name="btnsubmit" type="image"
								src="images/bseach.gif"></td>
						</tr>
					</table>
				</form>
			</td>
		</tr>
	</table>

	<div>
		<c:if test="${!empty graphUrl}">
			<img alt="图片丢失" src="${graphUrl}">
		</c:if>
	</div>




	<c:if test="${!empty montharr }">
		<!------------ 走势情况分析 ------------------->
		<div
			style="margin-left: 55px; padding: 10px; background-color: #FFEFEF; width: 950px; font-size: 14px;">
			<table cellspacing="1" width="100%">
				<tr>
					<td colspan="4" align="center" style="background-color: #CCC"><strong>价格走势数据分析</strong></td>
				</tr>
				<tr style="background-color: #CCCEEE">
					<td width="200">比较月份价格</td>
					<td width="200">本月份价格</td>
					<td>走势百分比</td>
					<td>走势情况说明</td>
				</tr>

				<c:forEach items="${montharr}" var="item" varStatus="statu">
					<c:if test="${statu.count>1}">
						<tr>
							<td width="150">￥ <c:forEach items="${montharr}" var="item1"
									varStatus="statu1">
									<c:if test="${statu1.count eq statu.index}">
										<fmt:formatNumber pattern="#0.00" value="${item1}"></fmt:formatNumber>
									</c:if>
								</c:forEach> (${statu.count-1}月)
							</td>
							<td><strong> ￥ <fmt:formatNumber pattern="#0.00"
										value="${item}"></fmt:formatNumber> (${statu.count}月)
							</strong></td>
							<td><c:forEach items="${montharr}" var="item1" varStatus="statu1">
									<c:choose>
										<c:when test="${(statu1.count eq statu.index)}">
											<c:choose>
												<c:when test="${item1 != 0 }">
													<c:choose>
														<c:when test="${(item-item1)>0 }">
															<img src="images/redArrow02.gif" alt="走高" title="走高">
														</c:when>
														<c:when test="${(item-item1)==0 }">
															持平
														</c:when>
														<c:otherwise>
															<img src="images/redArrow03-1.gif" alt="走低" title="走低">
														</c:otherwise>
													</c:choose>
													<fmt:formatNumber type="percent"
														value="${(item-item1)/item1}" minFractionDigits="2"></fmt:formatNumber>
												</c:when>
												<c:otherwise>
													<c:choose>
														<c:when test="${(item-item1)>0 }">
															<img src="images/redArrow02.gif" alt="走高" title="走高">
														</c:when>
														<c:otherwise>
															<img src="images/redArrow03-1.gif" alt="走低" title="走低">
														</c:otherwise>
													</c:choose>
													<fmt:formatNumber type="percent" value="${item}"
														minFractionDigits="2"></fmt:formatNumber>
												</c:otherwise>
											</c:choose>
										</c:when>
									</c:choose>
								</c:forEach></td>
							<td>
							<c:forEach items="${montharr}" var="item1" varStatus="statu1">
						     <c:if test="${statu1.count eq statu.index}">
						     	<c:choose>
									<c:when test="${(item-item1)>0 }">
										走高
									</c:when>
									<c:when test="${(item-item1)==0 }">
										持平
									</c:when>
									<c:otherwise>
										走低
									</c:otherwise>
								</c:choose>
						     </c:if>
							</c:forEach>
							</td>
						</tr>
					</c:if>
				</c:forEach>

			</table>
		</div>

		<!---------- 走势情况分析结束 ------------------->

	</c:if>




</body>
</html>
